1. Field of the Invention
This invention is related to the field of integrated circuits and, more particularly, to performing shifts in integrated circuits.
2. Description of the Related Art
Mask generation is one task that is often performed in integrated circuits such as processors. Generally, masks can be used to zero data that is not desired by bitwise ANDing the data with the mask. Data bits for which the corresponding mask bit is clear are cleared, and data bits for which the corresponding mask bit is set are unchanged. Similarly, a mask can be logically ORed with data to set bits for which the corresponding mask bit is set, and bits for which the corresponding mask bit is clear are not changed. An example of mask use is merging load data from multiple sources. Data from a given source that is not used in the merge can be masked off. A mask can be applied to the output of a rotator to create the effect of a shift (zeroing bits that are not part of the shift result). A mask can be used to zero certain address bits (e.g. the offset within a cache line, to fetch a cache line from memory).
Many masks have one transition from binary one to binary zero (or vice versa). That is, the mask has a set of binary ones on one side of the transition point and a set of binary zeros on the other side of the transition point. Typical mask generators decode a pointer that identifies the transition point, generating a vector of bits having a set bit representing the transition point, and clear bits in each other position. The mask bit for a given bit position can then be generated by logically ORing all the bits that are less significant than the bit position (or more significant that the bit position, depending on the type of mask being generated). However, such a mechanism uses wide OR gates, which are slow in static logic circuitry (and sometimes high in power consumption). To speed the generation, wide dynamic OR logic circuitry can be used, but the power consumption of the dynamic logic circuitry is even higher. A low power, high speed mask generator is desired.
Additionally, rotations and shifts are commonly performed in processors, typically in response to instructions. Generally, the rotates and shifts can be specified to occur in either direction (left or right). Some processors implement a rotator that rotates in one direction (say, left), and two's complement the rotate count for a rotate in the other direction (e.g. right) to produce the correct result. A shift can be performed using the rotator and a mask to mask off bits that are eliminated via the shift operation.